
<template>
  <ul class="todo-main">
    <Item v-for="(currentTodo, index) in todos" :todo="currentTodo" :index="index" :key="index"></Item>
  </ul>
</template>

<script>
import { inject } from 'vue'
import Item from './Item.vue'

export default {
  name: "List",
  setup(props, context){

    // 接受 app 组件中定义的 todo 对象
    const todos = inject('todos');

    return {
      todos
    }
  },
  components: {
    Item
  }
}
</script>

<style scoped>
/*main*/
.todo-main {
  margin-left: 0px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 0px;
}

todo-empty {
  height: 40px;
  line-height: 40px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding-left: 5px;
  margin-top: 10px;
}
</style>
